package models

import "gorm.io/gorm"

type GoodsPeople struct {
	gorm.Model
	Name    string `gorm:"type:varchar(20);not null;comment:'商品名字'"`
	Address string `gorm:"type:varchar(20);not null;comment:'距离'"`
	Num     int    `gorm:"type:int;not null;comment:'销量'"`
	Status  int    `gorm:"type:int;not null;comment:'营业状态 0 不在线 1 在线'"`
}

type Goods struct {
	gorm.Model
	Name   string  `gorm:"type:varchar(20);not null;comment:'商品名字'"`
	Price  float64 `gorm:"type:decimal(10,2);not null;comment:'价格'"`
	Num    int     `gorm:"type:int;not null;comment:'销量'"`
	Status int     `gorm:"type:int;not null;comment:'0 未上架 1 已上架'"`
	UserId int     `gorm:"type:int;not null;comment:'用户id'"`
}

type ShopPeople struct {
	gorm.Model
	Image      string `gorm:"type:varchar(200);not null;comment:'菜名图片'"`
	Peoplelogo string `gorm:"type:varchar(200);not null;comment:'商家Logo'"`
	Video      string `gorm:"type:varchar(20);not null;comment:'商家视频'"`
}

type You struct {
	gorm.Model
	Fa     string `gorm:"type:varchar(200);not null;comment:'优惠券发放'"`
	Give   string `gorm:"type:varchar(200);not null;comment:'领取优惠券'"`
	Use    string `gorm:"type:varchar(20);not null;comment:'使用优惠券'"`
	status string `gorm:"type:varchar(20);not null;comment:'核销'"`
}

func (g *Goods) GetGoods(goodsId int) error {
	return DB.Where(goodsId).Limit(1).Find(&g).Error
}

func (g *Goods) GoodsList() {
	DB.Debug().Limit(1).Find(&g).Order("price && num && status")
	return
}

func (s *ShopPeople) Create() error {
	return DB.Debug().Create(&s).Error
}

func (y *You) Create() error {
	return DB.Debug().Create(&y).Error
}
